package com.ruoyi.ai.controller;

import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.ruoyi.ai.service.ChatService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhaoYuFei
 */
@RestController
@RequestMapping("/tyqw")
public class TYQWController extends BaseController {
    @Autowired
    private ChatService chatService;

    @RequestMapping("/chat")
    public AjaxResult chatAi() throws NoApiKeyException, InputRequiredException {
        GenerationResult generationResult = chatService.chatAi();
        return success(generationResult);
    }
}
